package com.wwmz.pattern.factory.example;

import java.sql.Connection;
import java.util.Vector;

/**
 * Created by wumz on 2020/9/16 15:14
 */
public final class DBConnectionPool extends Pool {

    private int checkdOut;//正在使用的连接数

    private Vector<Connection> freeConnections = new Vector<>();//存放产生的连接对象容器

    private String passWord = null; //密码

    private String url = null; //连接字符串

    private String username = null; //用户名

    private static int num = 0; //空闲连接数

    private static int numActive = 0; //当前可用连接数

    private static DBConnectionPool pool = null; //连接池实例变量

    /**
     * 产生数据连接池
     */
    public static synchronized DBConnectionPool getInstance(){
        if (pool == null){
            pool = new DBConnectionPool();
        }
        return pool;
    }

    /**
     * 获得一个数据库连接池的实例
     */
    private DBConnectionPool(){
        try {
            init();
            for (int i=0; i<normalConnect; i++){
                Connection connection = null;
                if (connection != null){
                    freeConnections.addElement(connection);
                    num++;
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    /**
     *
     *
     *
     *
     *
     * .................................................................
     */





    @Override
    public void createPool() {

    }

    @Override
    public Connection getConnection() {
        return null;
    }

    @Override
    public Connection getConnection(long time) {
        return null;
    }

    @Override
    public void freeConnection(Connection connection) {

    }

    @Override
    public int getNum() {
        return 0;
    }

    @Override
    public int getNumActive() {
        return 0;
    }
}
